# -*- cmake -*-

# - Find BerkeleyDB
# Find the BerkeleyDB includes and library
# This module defines
#  DB_INCLUDE_DIR, where to find db.h, etc.
#  DB_LIBRARIES, the libraries needed to use BerkeleyDB.
#  DB_FOUND, If false, do not try to use BerkeleyDB.
# also defined, but not for general use are
#  DB_LIBRARY, where to find the BerkeleyDB library.

FIND_PATH(DBSTL_INCLUDE_DIR dbstl_common.h
/usr/local/include/db4
/usr/local/include
/usr/include/db4
/usr/include/db4.7
/usr/include/db4.8
/usr/include
)

SET(DBSTL_NAMES ${DBSTL_NAMES} "db_stl")
FIND_LIBRARY(DBSTL_LIBRARY
  NAMES ${DBSTL_NAMES}
  PATHS /usr/lib /usr/local/lib
  )

IF (DBSTL_LIBRARY AND DBSTL_INCLUDE_DIR)
    SET(DBSTL_LIBRARIES ${DBSTL_LIBRARY})
    SET(DBSTL_FOUND "YES")
ELSE (DBSTL_LIBRARY AND DBSTL_INCLUDE_DIR)
  SET(DBSTL_FOUND "NO")
ENDIF (DBSTL_LIBRARY AND DBSTL_INCLUDE_DIR)


IF (DBSTL_FOUND)
   IF (NOT DBSTL_FIND_QUIETLY)
      MESSAGE(STATUS "Found BerkeleyDBstl: ${DBSTL_LIBRARIES}")
   ENDIF (NOT DBSTL_FIND_QUIETLY)
ELSE (DBSTL_FOUND)
   IF (DBSTL_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "Could not find BerkeleyDBstl library")
   ENDIF (DBSTL_FIND_REQUIRED)
ENDIF (DBSTL_FOUND)

# Deprecated declarations.
SET (NATIVE_DBSTL_INCLUDE_PATH ${DBSTL_INCLUDE_DIR} )
GET_FILENAME_COMPONENT (NATIVE_DBSTL_LIB_PATH ${DBSTL_LIBRARY} PATH)

MARK_AS_ADVANCED(
  DBSTL_LIBRARY
  DBSTL_INCLUDE_DIR
  )
  